/*
 * @Description:
 * @Version: V1.0.0
 * @Author: 周艳凯 484894717@qq.com
 * @Date: 2025-02-26 11:42:02
 * @LastEditors: 周艳凯 484894717@qq.com
 * @LastEditTime: 2025-02-28 14:08:50
 * @FilePath: vite.config.ts
 * Copyright 2025 Marvin, All Rights Reserved.
 * 2025-02-26 11:42:02
 */
import { defineConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import { resolve } from 'path';
import { UnifiedViteWeappTailwindcssPlugin } from 'weapp-tailwindcss/vite';
import eslint from 'vite-plugin-eslint';

export default defineConfig(async () => {
  // 这里必须这样引用，因为 uni 只提供了 cjs 的版本且 uni-app 默认 cjs，而 @tailwindcss/vite 只提供了 esm 版本
  const { default: tailwindcss } = await import('@tailwindcss/vite');
  return {
    plugins: [
      uni(),
      tailwindcss(),
      UnifiedViteWeappTailwindcssPlugin({
        rem2rpx: true
      }),
      eslint()
    ],
    resolve: {
      alias: [
        {
          find: '@',
          replacement: resolve(__dirname, 'src') //配置@ 路径
        }
      ]
    }
  };
});
